<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>uCXpresso.BLE: CMailBox Class Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../upnp.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">uCXpresso.BLE
   &#160;<span id="projectnumber">v1.0.4</span>
   </div>
   <div id="projectbrief">RTOS C++ Framework for Bluetooth Low Energy</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="../../index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="../../modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="../../annotated.html"><span>Classes</span></a></li>
      <li><a href="../../examples.html"><span>Examples</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="../../search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="../../search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="../../annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="../../classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="../../hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="../../functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('d8/d26/class_c_mail_box.html','../../');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Groups</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="../../d6/d08/class_c_mail_box-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">CMailBox Class Reference<div class="ingroups"><a class="el" href="../../d8/dba/group___r_t_o_s.html">RTOS</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p><code>#include &quot;<a class="el" href="../../d1/d84/mailbox_8h_source.html">class/mailbox.h</a>&quot;</code></p>
<div class="dynheader">
Inheritance diagram for CMailBox:</div>
<div class="dyncontent">
 <div class="center">
  <img src="../../d8/d26/class_c_mail_box.png" usemap="#CMailBox_map" alt=""/>
  <map id="CMailBox_map" name="CMailBox_map">
<area href="../../dc/dac/class_c_object.html" alt="CObject" shape="rect" coords="0,0,66,24"/>
</map>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a860c64ec622b6bb2641f8e69748ba9e6"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d26/class_c_mail_box.html#a860c64ec622b6bb2641f8e69748ba9e6">CMailBox</a> (LPCTSTR name, int <a class="el" href="../../d8/d26/class_c_mail_box.html#a11592da3e55cf9bedc8d2cf36d56e9bd">count</a>=DEF_MAIL_COUNT)</td></tr>
<tr class="separator:a860c64ec622b6bb2641f8e69748ba9e6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad03ed94ae07a9309d9f42695c9df7e94"><td class="memItemLeft" align="right" valign="top">virtual MESSAGE_T&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d26/class_c_mail_box.html#ad03ed94ae07a9309d9f42695c9df7e94">wait</a> (uint32_t timeout=MAX_DELAY_TIME)</td></tr>
<tr class="separator:ad03ed94ae07a9309d9f42695c9df7e94"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adc923a33209756bb2ed9e1838b12b68c"><td class="memItemLeft" align="right" valign="top">virtual MESSAGE_T&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d26/class_c_mail_box.html#adc923a33209756bb2ed9e1838b12b68c">peek</a> (uint32_t timeout=MAX_DELAY_TIME)</td></tr>
<tr class="separator:adc923a33209756bb2ed9e1838b12b68c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a11592da3e55cf9bedc8d2cf36d56e9bd"><td class="memItemLeft" align="right" valign="top">virtual int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d26/class_c_mail_box.html#a11592da3e55cf9bedc8d2cf36d56e9bd">count</a> ()</td></tr>
<tr class="separator:a11592da3e55cf9bedc8d2cf36d56e9bd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5ab581cd317944e824efbbc6f7f4d14d"><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d26/class_c_mail_box.html#a5ab581cd317944e824efbbc6f7f4d14d">post</a> (MESSAGE_T msg, uint32_t timeout=MAX_DELAY_TIME)</td></tr>
<tr class="separator:a5ab581cd317944e824efbbc6f7f4d14d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a73d5b694b1e7ce4e05c7ccc8f1dfd695"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d26/class_c_mail_box.html#a73d5b694b1e7ce4e05c7ccc8f1dfd695">reset</a> ()</td></tr>
<tr class="separator:a73d5b694b1e7ce4e05c7ccc8f1dfd695"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a26a76c241a4d62d2efdac57d2cfe4c0f"><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dc/dac/class_c_object.html#a26a76c241a4d62d2efdac57d2cfe4c0f">isThread</a> ()</td></tr>
<tr class="separator:a26a76c241a4d62d2efdac57d2cfe4c0f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:a96075bbd5308e6b1d0aaf5bd5fa2e645"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d26/class_c_mail_box.html#a96075bbd5308e6b1d0aaf5bd5fa2e645">post</a> (LPCTSTR name, MESSAGE_T msg, uint32_t timeout=0)</td></tr>
<tr class="separator:a96075bbd5308e6b1d0aaf5bd5fa2e645"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Use the CMailbox to receive a message pointer from sender. </p>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="../../db/de1/_2misc_2garbage_collector_2src_2main_8cpp-example.html#_a0">/misc/garbage_collector/src/main.cpp</a>.</dd>
</dl></div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a860c64ec622b6bb2641f8e69748ba9e6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">CMailBox::CMailBox </td>
          <td>(</td>
          <td class="paramtype">LPCTSTR&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>count</em> = <code>DEF_MAIL_COUNT</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Constructs a <a class="el" href="../../d8/d26/class_c_mail_box.html">CMailBox</a> object. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">name</td><td>is a string to point to describe the name of mailbox. </td></tr>
    <tr><td class="paramname">count</td><td>is a integer value to specified the maximum number of message can be contain.</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line">Example:</div>
<div class="line">        <span class="keyword">class </span>CLedTask: <span class="keyword">public</span> <a class="code" href="../../d0/d26/class_c_thread.html">CThread</a> {</div>
<div class="line">        <span class="keyword">protected</span>:</div>
<div class="line">            <span class="keyword">virtual</span> <span class="keywordtype">void</span> run() {</div>
<div class="line">            <a class="code" href="../../de/d89/class_c_bus.html">CBus</a> leds(<a class="code" href="../../db/dff/group___enumerations.html#gga65a2241721e4acb573e0c3fe29ac432fa8379bbaa96d151e6adac488b2a147b7a">LED2</a>, <a class="code" href="../../db/dff/group___enumerations.html#gga65a2241721e4acb573e0c3fe29ac432fa5dec293e081e0fc78369c842fab8452b">LED3</a>, <a class="code" href="../../db/dff/group___enumerations.html#gga65a2241721e4acb573e0c3fe29ac432fad60e39b8d1701d30aa64f80343217342">LED4</a>, <a class="code" href="../../db/dff/group___enumerations.html#gga65a2241721e4acb573e0c3fe29ac432fadc6f24fd6915a3f2786a1b7045406924">END</a>);</div>
<div class="line">            <a class="code" href="../../d8/d26/class_c_mail_box.html">CMailBox</a> mail(<span class="stringliteral">&quot;LED&quot;</span>);</div>
<div class="line">            <span class="keywordtype">int</span> *i;</div>
<div class="line">            <span class="keywordflow">while</span>(1) {</div>
<div class="line">                i = (<span class="keywordtype">int</span> *) mail.wait();</div>
<div class="line">                <span class="keywordflow">if</span> ( i ) {</div>
<div class="line">                    leds[*i] = !leds[*i];</div>
<div class="line">                }</div>
<div class="line">            }</div>
<div class="line">            }</div>
<div class="line">    };</div>
</div><!-- fragment --> 
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a11592da3e55cf9bedc8d2cf36d56e9bd"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual int CMailBox::count </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Call the member function to retrieve the number of message stored in the mailbox. </p>
<dl class="section return"><dt>Returns</dt><dd>number of message. </dd></dl>

</div>
</div>
<a class="anchor" id="a26a76c241a4d62d2efdac57d2cfe4c0f"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual bool CObject::isThread </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">virtual</span><span class="mlabel">inherited</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Check current object that inherits from <a class="el" href="../../d0/d26/class_c_thread.html">CThread</a> class or not. </p>
<dl class="section note"><dt>Note</dt><dd>The isTherad() will be override by <a class="el" href="../../d0/d26/class_c_thread.html">CThread</a> class. </dd></dl>

<p>Reimplemented in <a class="el" href="../../d0/d26/class_c_thread.html#ab2513fd0fcad30e2e6605609c91f1984">CThread</a>.</p>

</div>
</div>
<a class="anchor" id="adc923a33209756bb2ed9e1838b12b68c"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual MESSAGE_T CMailBox::peek </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>timeout</em> = <code>MAX_DELAY_TIME</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Receive a message from mail box without remove </p>

</div>
</div>
<a class="anchor" id="a5ab581cd317944e824efbbc6f7f4d14d"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual bool CMailBox::post </td>
          <td>(</td>
          <td class="paramtype">MESSAGE_T&#160;</td>
          <td class="paramname"><em>msg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>timeout</em> = <code>MAX_DELAY_TIME</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Call the member function to send a message to receiver </p>

</div>
</div>
<a class="anchor" id="a96075bbd5308e6b1d0aaf5bd5fa2e645"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static bool CMailBox::post </td>
          <td>(</td>
          <td class="paramtype">LPCTSTR&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">MESSAGE_T&#160;</td>
          <td class="paramname"><em>msg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>timeout</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Call the member function to send a message to receiver which the same mailbox name. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">name</td><td>is a string to point to which the same name of mailbox to be received the message. </td></tr>
    <tr><td class="paramname">msg</td><td>is a pointer to the message (void*). </td></tr>
    <tr><td class="paramname">timeout</td><td>is a time to wait for post. (Default zero) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if post the message successful; otherwise, pose failed.</dd></dl>
<div class="fragment"><div class="line">Example:</div>
<div class="line">    <span class="keyword">class </span>Task1: <span class="keyword">public</span> <a class="code" href="../../d0/d26/class_c_thread.html">CThread</a> {</div>
<div class="line">    <span class="keyword">protected</span>:</div>
<div class="line">    <span class="keyword">virtual</span> <span class="keywordtype">void</span> run() {</div>
<div class="line">        <span class="keywordtype">int</span> i=0;</div>
<div class="line">        <span class="keywordflow">while</span>(1) {</div>
<div class="line">            <a class="code" href="../../d8/d26/class_c_mail_box.html#a5ab581cd317944e824efbbc6f7f4d14d">CMailBox::post</a>(MAIL_LED, &amp;i);</div>
<div class="line">            sleep(500);</div>
<div class="line">        }</div>
<div class="line">    }</div>
<div class="line"> };</div>
</div><!-- fragment --> <dl class="section remark"><dt>Remarks</dt><dd>The <a class="el" href="../../d8/d26/class_c_mail_box.html#a5ab581cd317944e824efbbc6f7f4d14d">CMailBox::post</a> is a static function. </dd></dl>

</div>
</div>
<a class="anchor" id="a73d5b694b1e7ce4e05c7ccc8f1dfd695"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void CMailBox::reset </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Reset the mail box to original empty state. </p>

</div>
</div>
<a class="anchor" id="ad03ed94ae07a9309d9f42695c9df7e94"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual MESSAGE_T CMailBox::wait </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>timeout</em> = <code>MAX_DELAY_TIME</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Call the member function to wait a message from sender. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">timeout</td><td>is an amount of time the task should block for a message to receive. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>MESSAGE_T </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="../../d8/d26/class_c_mail_box.html">CMailBox</a></li>
    <li class="footer">Generated on Fri Apr 11 2014 23:43:26 for uCXpresso.BLE by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="../../doxygen.png" alt="doxygen"/></a> 1.8.6 </li>
  </ul>
</div>
</body>
</html>
